package com.yunhui.admin.model;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.yunhui.entity.YCAdmin;

/**
 * 用户登录配置类
 * @author Administrator
 *
 */
public class AdminUserDateils implements UserDetails {

	private static final long serialVersionUID = -1546619839676530441L;
	
	 private transient YCAdmin yCAdmin;

	 public AdminUserDateils() {
	}

	    public AdminUserDateils(YCAdmin yCAdmin) {
	        if (yCAdmin != null) {
	            this.yCAdmin = yCAdmin;
	        }
	    }
	

	    
	public YCAdmin getyCAdmin() {
			return yCAdmin;
		}

		public void setyCAdmin(YCAdmin yCAdmin) {
			this.yCAdmin = yCAdmin;
		}

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		 Collection<GrantedAuthority> authorities = new ArrayList<>();
	        SimpleGrantedAuthority authority = new SimpleGrantedAuthority("admin");
	        authorities.add(authority);
	        return authorities;
	}

	@Override
	public String getPassword() {
	
		 return yCAdmin.getAdminPassword();
	}

	@Override
	public String getUsername() {
		
		return yCAdmin.getAdminAccount();
	}

	@Override
	public boolean isAccountNonExpired() {
		
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		
		return true;
	}

	@Override
	public boolean isEnabled() {
		
		return true;
	}

}
